package chapter06

/**
 *
 * @author cdhuangchao3
 * @date 2023/6/9 7:57 PM
 */
object Test15_TraitOverlying {
  def main(args: Array[String]): Unit = {
    val student = new Student15
    student.increase()

    // 钻石问题特质叠加
    val myFootBall = new MyFootBall
    println(myFootBall.describe())
  }
}

trait Knowledge15 {
  var amount: Int = 0

  def increase() = {
    println("knowledge increased")
  }
}

trait Ball {
  def describe() = "ball"
}

// 颜色特质
trait ColorBall extends Ball {
  val color: String = "red"

  override def describe(): String = color + "-" + super.describe()
}

// 种类特质
trait CategoryBall extends Ball {
  var category = "foot"

  override def describe(): String = category + "-" + super.describe()
}

// 自定义球类
class MyFootBall extends CategoryBall with ColorBall {
  override def describe(): String = "my ball is a "+super[ColorBall].describe()
}

trait Talent15 {
  def singing(): Unit

  def dancing(): Unit

  def increase(): Unit = {
    println("talent increased")
  }
}

class Student15 extends Person13 with Knowledge15 with Talent15 {
  override def singing(): Unit = println("singing")

  override def dancing(): Unit = println("dancing")

  override def increase(): Unit = super.increase()
}